package com.ty.init.interceptor;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.util.ArrayList;

/**
 * @author ty
 */
@Configuration
public class LoginInterceptorConfig implements WebMvcConfigurer {
    HandlerInterceptor interceptor = new LoginInterceptor();

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration
                = registry.addInterceptor(interceptor);
        // 拦截请求
        registration.addPathPatterns("/**");
        // 放行请求
        registration.excludePathPatterns(
                "/login",
                "/users/**",
                "/layui/**",
                "/lib/**",
                "/img/**",
                "/webjars/**"
        );
    }
}
